<?php

class SmsModel
{
    private $mobileCodeKeyPrefix = 'MBC/';

    public function addMobileCode($mobile, $codeType, $code, $uid, $ip) {
        if (empty($mobile) || empty($code) || empty($codeType)) {
            AC::$errorNo    =   'AUM005';
            return FALSE;
        }

        $key   	   =   $this->mobileCodeKeyPrefix. 0;
        $data      =   $this->assembleMobileCodeDataOfMysql($uid, $mobile, $code, $codeType, $ip);
        $result	   =   Storage::addData($key, $data);
        return $result;
    }

    private function assembleMobileCodeDataOfMysql ($uid, $phone, $code, $type, $ip) {
        if (empty($phone) || empty($code)) {
            return false;
        }

        $data = array(
            'uid'   =>  $uid,
            'phone' =>  $phone,
            'code'  =>  $code,
            'type'  =>  $type,
            'area'  =>  '86',
            'ip'    =>  $ip,
            'time'  =>  AC::SERVER_TIME
        );

        return $data;
    }
}